package com.qfedu.yanglao20admin.orderlist.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qfedu.yanglao20admin.orderlist.dao.OredrListVODao;
import com.qfedu.yanglao20admin.orderlist.service.OrderListVOService;
import com.qfedu.yanglao20admin.orderlist.vo.OrderListVO;
import com.qfedu.yanglao20admin.orderlist.common.StateEnum;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * User:  yunk
 * Date 2023/5/3  9:46
 */
@Service
public class OrderListVOServiceImpl implements OrderListVOService {
    @Resource
    private OredrListVODao oredrListVODao;

    @Override
    public Page<OrderListVO> selectPage(OrderListVO orderList) {
        Page page = new Page<OrderListVO>((orderList.getPageNum() - 1) * orderList.getPageSize(),
                orderList.getPageSize());
        orderList.setOffset((orderList.getPageNum() - 1) * orderList.getPageSize());
        List<OrderListVO> listVOS = oredrListVODao.selectPage(orderList);
        for (OrderListVO ov :
                listVOS
        ) {
            StateEnum stateEnum = StateEnum.getStateById(ov.getState());
            ov.setStateMent(stateEnum.getDesc());
        }
        page.setRecords(listVOS);
        page.setTotal(oredrListVODao.selectCount(null));
        return page;
    }
}
